SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE PROC [dbo].[PCommisINSERT]
@idPrepod ListCommisTable READONLY
AS
BEGIN TRAN
BEGIN TRY 
DECLARE @Temp INT;
INSERT INTO Commis
(DateApp,DateAdd)
VALUES
(GETDATE(),GETDATE())
SET @Temp=@@IDENTITY;
INSERT INTO ListCommis 
          (itab_n,Ik_Status,Ik_Commis)
        SELECT itab_n, Ik_Status, @Temp  
        FROM  @idPrepod  
END TRY
BEGIN CATCH
	if @@TRANCOUNT>0
		begin
			raiserror ('Произошла ошибка добавления комиcсии!',1,2)
			rollback
		end
END CATCH
if @@TRANCOUNT>0
COMMIT TRAN
GO
